﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace University.Workshop.WinApp
{
    public partial class Radiographie : Form
    {
        OpenFileDialog openFile = new OpenFileDialog();
        
        public Radiographie()
        {
            InitializeComponent();
            this.listViewRadiographis.View = View.LargeIcon;
            this.listViewRadiographis.LargeImageList = this.imageListMedium;
            LoadRadiographis();
        }

        private void LoadRadiographis()
        {      
            
            for (int i = 0; i < imageListMedium.Images.Count; i++) 
            {
                ListViewItem picture = new ListViewItem();
                picture.ImageIndex = i;                
                this.listViewRadiographis.Items.Add(picture);                              
            }
        }

        private void comboBoxView_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBoxView.Text == "Extra Large Icons")
            {                
                //this.imageListView.ImageSize = new System.Drawing.Size(50,50); 
                this.listViewRadiographis.Items.Clear();
                this.listViewRadiographis.View = View.LargeIcon;
                this.listViewRadiographis.LargeImageList = this.imageListExtraLarge;
                LoadRadiographis(); 
            }
            if (comboBoxView.Text == "Large Icons")
            {
                this.listViewRadiographis.Items.Clear();
                this.listViewRadiographis.View = View.LargeIcon;
                this.listViewRadiographis.LargeImageList = this.imageListLarge;
                LoadRadiographis();
            }
            if (comboBoxView.Text == "Medium Icons")
            {
                this.listViewRadiographis.Items.Clear();
                this.listViewRadiographis.View = View.LargeIcon;
                this.listViewRadiographis.LargeImageList = this.imageListMedium;
                LoadRadiographis();
            }
            if (comboBoxView.Text == "Small Icons")
            {
                this.listViewRadiographis.Items.Clear();
                this.listViewRadiographis.View = View.LargeIcon;
                this.listViewRadiographis.LargeImageList = this.imageListSmall;
                LoadRadiographis();
            }
        }

        private void buttonLoadImage_Click(object sender, EventArgs e)
        {
            if (openFile.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                pictureBoxImageXRay.ImageLocation = openFile.FileName;
            }
        }

        private void buttonRevertImage_Click(object sender, EventArgs e)
        {
            pictureBoxImageXRay.Image = global::University.Workshop.WinApp.Properties.Resources.xrayImage;
        }        

        private void listViewRadiographis_Click(object sender, EventArgs e)
        {
            ViewImageXRay xray = new ViewImageXRay(imageListLarge.Images[int.Parse(listViewRadiographis.SelectedIndices[0].ToString())]);
            xray.ShowDialog();
        }
    }
}
